<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 封装一个输入半径求圆的面积的函数。
 

      function fn(num){
        var b=Math.PI;
        if(num>0){
            var a=b*num*num;
        }
        return (`圆的面积为${a}`);

      }
      document.write(fn(prompt("请输入半径")));
    </script>
  </body>
</html>
